package com.example.ixform.controllers;

import com.example.ixform.dao.CommentRepository;
import com.example.ixform.dao.NetizenRepository;
import com.example.ixform.dto.NetizenComment;
import com.example.ixform.entities.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class HomeController {

    @Autowired
    CommentRepository commentRepository;

    @Autowired
    NetizenRepository netizenRepository;

    @GetMapping("/")
    public String displayHome(Model model){

        List<Comment> comments = commentRepository.findAll();
        model.addAttribute("comments",comments);

        List<Comment> netizens = commentRepository.findAll();
        model.addAttribute("netizens",netizens);

        return "main/index";

    }
}
